import React from "react";
import { Bi, Ei, Pi } from "@/module-00-codebase/pkg-01-container";
import * as style from "./style";
import { asyncWait } from "@/module-00-codebase/pkg-02-tool";
export class MtDialog {
  public on(anything: any): void {
    let content: any;
    if (typeof anything === "string") {
      content = Pi[anything] || <Ei.Text params={[`Page [${anything}] Not Found!`]} />;
    } else if (!anything) {
      content = <Ei.Text params={["Empty Dialog"]} />;
    } else {
      content = anything;
    }
    asyncWait(async () => {
      const cover = await Bi.cover.on();
      Bi.renderer.render(
        <Ei.Layout params={[]} className={style.container}>
          <Ei.Layout params={[]} className={style.cover} />
          <Ei.Layout params={[]} className={style.contentContainer}>
            {content}
          </Ei.Layout>
        </Ei.Layout>,
        cover
      );
    }, LOCK);
  }
  public off(): void {
    asyncWait(async () => {
      await Bi.cover.off();
    }, LOCK);
  }
}
export const dependencies = () => ["Utils"];
const LOCK = Symbol();
